package com.xfcy.blog.controller.system;



import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.xfcy.blog.annotation.OperationLogger;
import com.xfcy.blog.common.R;
import com.xfcy.blog.entity.Photo;
import com.xfcy.blog.service.PhotoService;
import com.xfcy.blog.strategy.FileUploadStrategy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 照片(Photo)表控制层
 *
 * @author 晓风残月Lx
 * @since 2023-04-09 11:03:06
 */
@RestController
@RequestMapping("system/photo")
@Api(tags = "后台相片管理")
public class PhotoController {

    @Resource
    private PhotoService photoService;

    @GetMapping("/list")
    @ApiOperation(value = "后台相片列表", httpMethod = "GET", response = R.class, notes = "后台相册列表")
    @SaCheckLogin
    public R list(Integer pageNo, Integer pageSize, Integer albumId) {
        return photoService.listPhoto(pageNo, pageSize, albumId);
    }

    @OperationLogger(value = "移动相片")
    @PostMapping("/movePhoto")
    @SaCheckPermission("/system/photo/movePhoto")
    @ApiOperation(value = "移动相片", httpMethod = "GET", response = R.class, notes = "移动相片")
    public R movePhoto(@RequestBody Map<String,Object> map) {
        return photoService.movePhoto(map);
    }

    @OperationLogger(value = "相片详情")
    @GetMapping("/info")
    @SaCheckPermission("/system/photo/info")
    @ApiOperation(value = "相片详情", httpMethod = "GET", response = R.class, notes = "相片详情")
    public R info(Integer id) {
        return photoService.getPhotoById(id);
    }

    @OperationLogger(value = "添加照片")
    @PostMapping("/add")
    @SaCheckPermission("/system/photo/add")
    @ApiOperation(value = "添加照片", httpMethod = "POST", response = R.class, notes = "添加照片")
    public R insertAlbum(@RequestBody Photo photo) {
        return photoService.insertPhoto(photo);
    }

    @OperationLogger(value = "修改照片")
    @PostMapping(value = "/update")
    @SaCheckPermission("/system/photo/update")
    @ApiOperation(value = "修改照片", httpMethod = "POST", response = R.class, notes = "修改照片")
    public R updateAlbum(@RequestBody Photo photo) {
        return photoService.updatePhoto(photo);
    }

    @OperationLogger(value = "批量删除图片")
    @DeleteMapping("/deleteBatch")
    @SaCheckPermission("/system/photo/deleteBatch")
    @ApiOperation(value = "批量删除图片", httpMethod = "DELETE", response = R.class, notes = "批量删除图片")
    public R deleteBatchPhoto(@RequestBody List<Integer> ids) {
        return photoService.deleteBatchPhoto(ids);
    }


}

